﻿using System.Collections.Generic;
using DevelopTool.Forms.ChatForms;
using DevelopTool.Forms.CodeForms;
using DevelopTool.Forms.DataConversionForms;
using DevelopTool.Forms.DbForms;
using DevelopTool.Forms.DbForms.DbLockWatchForms;
using DevelopTool.Forms.DbForms.TableRelationForms;
using DevelopTool.Forms.DocumentForms;
using DevelopTool.Forms.EncodOrEncrypForms;
using DevelopTool.Forms.FolderToolForms;
using DevelopTool.Forms.ImageToolForms;
using DevelopTool.Forms.LuckDrawForms;
using DevelopTool.Forms.NoteForms;
using DevelopTool.Forms.OffLineForms;
using DevelopTool.Forms.RemoteForms;
using DevelopTool.Forms.SafetyForms;
using DevelopTool.Forms.SchedulerForms;
using DevelopTool.Forms.SystemToolForms;
using DevelopTool.Forms.TextProcessForms;
using DevelopTool.Forms.TipsForms;
using DevelopTool.Forms.ToolForms;
using DevelopTool.Forms.ToolForms.DesktopClock;
using DevelopTool.Model;
using WindowTextExtractor.Forms;

namespace DevelopTool.Forms.CommonHelpers
{
    public static class SystemMenu
    {
        /// <summary>
        /// 系统功能菜单集合
        /// </summary>
        public static List<SystemMenuModel> List = new List<SystemMenuModel>()
        {
            new SystemMenuModel
            {
                Text = "关于", Symbol = 361530,IsShowToSysMenu=false
            },
            new SystemMenuModel
            {
                Text = "开源项目", Symbol = 362721,IsShowToSysMenu=false
            },
            new SystemMenuModel
            {
                Text = "更新日志", Symbol = 559683,IsShowToSysMenu=false
            },
            new SystemMenuModel
            {
                Text = "首次使用", Symbol = 162730,IsShowToSysMenu=false, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "主界面", Symbol = 61461
                    },
                    new SystemMenuModel
                    {
                        Text = "注册", Symbol = 62004
                    },
                    new SystemMenuModel
                    {
                        Text = "登录", Symbol = 57453
                    },
                }
            },
            new SystemMenuModel
            {
                Text = "数据库", Symbol = 362750, SymbolSize = 26,IsCloseConfirm=false, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "数据库资源", Symbol = 362750,IsCloseConfirm=true, FormType = typeof(DbManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "数据库全文检索", Symbol = 559520, FormType = typeof(DbSearchForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "数据库锁表监控", Symbol = 563731,IsCloseConfirm=false, FormType = typeof(DbLockWatchForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "Sql分析", Symbol = 61635, FormType = typeof(SqlAnalyzeForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "数据库表关系分析", Symbol = 357659, FormType = typeof(TableRelationManageForm), FormShowType = FormShowType.Page
                    }
                }
            },
            new SystemMenuModel
            {
                Text = "应用", Symbol = 361874, SymbolSize = 25, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "笔记", Symbol = 361485, FormType = typeof(NoteManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "代码库", Symbol = 362972, FormType = typeof(CodeManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "离线数据", Symbol = 361468, FormType = typeof(OffLineManageForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "远程连接", Symbol = 361912, FormType = typeof(RemoteManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "选择困难症", Symbol = 362860, FormType = typeof(LuckDrawManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "提醒事项", Symbol = 558265, FormType = typeof(TipsManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "定时任务", Symbol = 559571, FormType = typeof(SchedulerManageForm), FormShowType = FormShowType.Page
                    },
                    new SystemMenuModel
                    {
                        Text = "知识消消乐", Symbol = 560206, FormType = typeof(SchedulerManageForm), FormShowType = FormShowType.Page
                    }
                }
            },
            new SystemMenuModel
            {
                Text = "工具集", Symbol = 362973, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "代码编辑器", Symbol = 361897, FormType = typeof(CodeFormatForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "Markdown编辑器", Symbol = 61750, FormType = typeof(MarkdownEditorForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "Markdown编辑器2", Symbol = 61750, FormType = typeof(MarkdownEditorForm2), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "网页浏览器", Symbol = 61750, FormType = typeof(WebBrowserForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "程序集相关", Symbol = 357462, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "查看程序集",IsCloseConfirm=false, Symbol = 561248, FormType = typeof(ILSpyForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "搜索程序集",IsCloseConfirm=false, Symbol = 162443, FormType = typeof(SearchAssemblyForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "文本工具", Symbol = 361493, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "根据模板生成文本",Symbol=559618, FormType = typeof(GenerateTextByTemplateForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "生成随机文本",Symbol=558412, FormType = typeof(GenerateRandomTextForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "生成GUID唯一码",Symbol=561461, FormType = typeof(GenerateGUIDForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "文本转大小写",Symbol=560130, FormType = typeof(ConvertToUpper_LowerForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "辅助输入",IsCloseConfirm=false, Symbol = 62042, FormType = typeof(AuxiliaryInputForm), FormShowType = FormShowType.Page
                            },
                            new SystemMenuModel
                            {
                                Text = "根据脚本生成实体代码", Symbol = 559503, FormType = typeof(GenerateEntitiesOnScriptForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "数据换算", Symbol = 560103, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "时间戳转换",IsCloseConfirm=false,Symbol=561443, FormType = typeof(TimestampConversionForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "存储容量换算",IsCloseConfirm=false,Symbol=558423, FormType = typeof(StorageConversionForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "时间换算",IsCloseConfirm=false,Symbol=560221, FormType = typeof(TimeConversionForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "图片工具", Symbol = 558294, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "图片浏览器",IsCloseConfirm=false, Symbol = 363612, FormType = typeof(ImageViewForm), FormShowType = FormShowType.Page
                            },
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "文件(夹)工具", Symbol = 61564, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "提取文件名", Symbol = 362828, FormType = typeof(FileNameQueryByExtensionForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "目录监控", Symbol = 358603, FormType = typeof(FolderWatcherForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                             new SystemMenuModel
                            {
                                Text = "查看目录大小",IsCloseConfirm=false, Symbol = 363490, FormType = typeof(FolderSizeForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "加解密&&编解码", Symbol = 561506, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "Base64文本编解码",Symbol=559708, FormType = typeof(Base64TextForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "Base64与图片互转", Symbol=559709,FormType = typeof(Base64ImageForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            },
                            new SystemMenuModel
                            {
                                Text = "URL编解码",Symbol=361633, FormType = typeof(UrlEncodeForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                            }
                        }
                    },
                    new SystemMenuModel
                    {
                        Text = "系统工具", Symbol = 161818, ChildMenus = new List < SystemMenuModel >
                        {
                            new SystemMenuModel
                            {
                                Text = "电脑环境",IsCloseConfirm=false, Symbol = 358597, FormType = typeof(SystemEnvironmentForm), FormShowType = FormShowType.Page
                            },
                            new SystemMenuModel
                            {
                                Text = "Wifi固定器",IsCloseConfirm=false, Symbol = 560267, FormType = typeof(WiFiFixatorForm), FormShowType = FormShowType.Page
                            },
                            new SystemMenuModel
                            {
                                Text = "电源计划",IsCloseConfirm=false, Symbol = 560442, FormType = typeof(PowerPlanForm), FormShowType = FormShowType.Page
                            },
                            new SystemMenuModel
                            {
                                Text = "关机&&重启", Symbol = 61457, FormType = typeof(ShutdownPlanForm), FormShowType = FormShowType.Page
                            },
                            new SystemMenuModel
                            {
                                Text = "端口进程扫描",IsCloseConfirm=false, Symbol = 162883, FormType = typeof(ScanPortForm), FormShowType = FormShowType.Page
                            }
                        }
                    },
                }
            },
            new SystemMenuModel
            {
                Text = "独立工具", Symbol = 362802, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "局域网聊天", Symbol = 560317, FormType = typeof(ChatMainForm), FormShowType = FormShowType.Show
                    },
                    new SystemMenuModel
                    {
                        Text = "截图&&二维码", Symbol = 558424, FormType = typeof(ScreenShotForm), FormShowType = FormShowType.Show
                    },
                    new SystemMenuModel
                    {
                        Text = "窗口文本提取", Symbol = 558716, FormType = typeof(GetWindowTextForm), FormShowType = FormShowType.Show
                    },
                    new SystemMenuModel
                    {
                        Text = "桌面时钟", Symbol = 561398, FormType = typeof(DesktopClockForm), FormShowType = FormShowType.Show
                    },
                    //new SystemMenuModel
                    //{
                    //    Text = "浏览器", Symbol = 162059, FormType = typeof(WebBrowserForm), FormShowType = FormShowType.Page
                    //}
                }
            },
            new SystemMenuModel
            {
                Text = "文档资料", Symbol = 559929,IsCloseConfirm=false, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "Oracle常用函数", Symbol = 557930, IsCloseConfirm=false,FormType = typeof(OracleCommonFunctionForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "Linux命令手册", Symbol = 161820, IsCloseConfirm=false,FormType = typeof(LinuxCommandForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "CMD命令手册", Symbol = 560135,IsCloseConfirm=false, FormType = typeof(CmdCommandForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                    new SystemMenuModel
                    {
                        Text = "开发文档备忘录", Symbol = 357531,IsCloseConfirm=false, FormType = typeof(DevelopDocumentForm), FormShowType = FormShowType.Page, AllowMultipleOpen = true
                    },
                }
            },
            new SystemMenuModel
            {
                Text = "扩展插件", Symbol = 162453, ChildMenus = new List < SystemMenuModel > ()
                {
                }
            },
            new SystemMenuModel
            {
                Text = "选项", Symbol = 61573, SymbolSize = 25, IsShowToSysMenu=false, ChildMenus = new List < SystemMenuModel > ()
                {
                    new SystemMenuModel
                    {
                        Text = "设置", Symbol = 61459
                    },
                    new SystemMenuModel
                    {
                        Text = "主题", Symbol = 61668
                    },
                    new SystemMenuModel
                    {
                        Text = "切换用户", Symbol = 559933
                    },
                    new SystemMenuModel
                    {
                        Text = "本地数据库导出", Symbol = 557705
                    },
                    new SystemMenuModel
                    {
                        Text = "配置文件导出", Symbol = 362836
                    },
                    new SystemMenuModel
                    {
                        Text = "配置飞书消息", Symbol = 358719,IsShowToSysMenu = false,
                    },
                }
            },
            new SystemMenuModel
            {
                Text = "锁定", Symbol = 57452, FormType=typeof(LockForm), FormShowType = FormShowType.Custom
            },
        };


        /// <summary>
        /// 递归查找系统菜单集合节点
        /// </summary>
        /// <param name="text">要查找的节点名称</param>
        /// <param name="nodes">要搜索的集合对象</param>
        /// <returns>匹配的 TreeNode 对象，如果未找到则返回 null</returns>
        public static SystemMenuModel GetMenuByText(string text,List<SystemMenuModel> list)
        {
            // 遍历每个节点
            foreach(SystemMenuModel systemMenu in list)
            {
                // 如果找到匹配的节点
                if(systemMenu.Text == text)
                {
                    return systemMenu; // 找到目标节点，立即返回
                }

                // 递归查找子节点
                SystemMenuModel foundMenu = GetMenuByText(text,systemMenu.ChildMenus);
                if(foundMenu != null)
                {
                    return foundMenu; // 在子节点中找到目标节点，立即返回
                }
            }

            // 遍历所有节点后仍未找到目标节点
            return null;
        }
    }
}
